mui.init()
//mui.plusReady(function() {
//	var self = plus.webview.currentWebview();
//	self.setStyle({
//		bounce: "vertical",
//		bounceBackground: "red"
//	});
Vue.use(VueLazyload, {
	preLoad: 1.3,
	error: '../../images/noimg.jpg',
	loading: '../../images/noimg.jpg'
});
var my = new Vue({
	el: '#my',
	data: {
		imgCommonUrl: common.imageUrl,
		data: ''
	},
	mounted: function() {
		var self = this
		common.ajax('/p/userhome', {}, function(data) {
			if(data.code == 1) {
				self.data = data.data
				localStorage.setItem('userMyName', JSON.stringify(data.data))
			} else {
				if(data.resultMsg) {
					mui.toast(data.resultMsg)
				}
			}
		}, false, 'get')
	},
	methods: {
		consultation: function() {
			mui.openWindow({
				id: "../mask/nesting.html",
				url: '../mask/nesting.html',
				extras: {
					url: 'http://p.qiao.baidu.com/cps/chat?siteId=11390067&userId=24711168'
				}
			});
		}
	}
})

//退出登陆
$(".signOut").on('tap', function() {
	var btnArray = ['是', '否'];
	mui.confirm('您确定退出登录?', '', btnArray, function(e) {
		if(e.index == 0) {

			common.ajax('/userCore/loginOut', {}, function(data) {
				console.log(data)
			})
			localStorage.removeItem('userData')
			var wvs, self, launch;
			wvs = plus.webview.all();
			self = plus.webview.currentWebview();
			launch = plus.webview.getLaunchWebview();
			for(var i = 0, len = wvs.length; i < len; i++) {
				if(wvs[i].getURL() == self.getURL() || wvs[i].getURL() == launch.getURL() || wvs[i].id == 'ylindex.html' || wvs[i].id == 'home.html') {
					continue;
				}
				wvs[i].close();
			}
			plus.storage.clear();
			var list = plus.webview.getWebviewById("ylindex.html")
			mui.fire(list, 'gohome')
			plus.webview.open('../login/login.html', '../login/login.html', {}, 'slide-in-right')
			self.close();
		}
	})
})
$(".order_cls").on('tap', function() {
	$(this).find('.promote').remove()
	common.open('../my/order.html', '../my/order.html', $(this).index() + 1)
})

//})

var _toast = false
mui.back = function() {
	if(!_toast || !_toast.isVisible()) {
		_toast = mui.toast('再按一次返回键退出', {
			type: 'div'
		});
	} else {
		var main = plus.android.runtimeMainActivity();
    main.moveTaskToBack(false);
	}
}